#ifndef TEMPERATURE_H
#define TEMPERATURE_H

#include <QObject>
#include <unistd.h>
#define CPU_HAS_SENSOR          // cpu温度传感器宏，需注意，CPU sensor寄存器地址偏移

class Temperature
{
public:
    enum CPUTYPE{
        FT1500A,
        FT2004,
    };
    Temperature();
    ~Temperature();
    void SwitchSensor(bool on);     // 打开/关闭温度监测
    int GetCpuTemperature();        // 获取CPU温度, 为实际值*1000
    float GetVideoTemperature();      // 获取显卡温度，为实际值
    float GetHddTemperature();        // 获取硬盘温度，为实际值

private:
    int            memDev_fd;
    unsigned char *map_base;
    unsigned char *data_base;
    size_t         map_len;
    CPUTYPE        cpu_type;

    quint32 mmioRead32(int offsetAddr);
    void    mmioWrite32(int offsetAddr, quint32 value);
    int     cpu_calc_temprature(int sensor_val);
};

#endif // TEMPERATURE_H
